Create alignment for smart line
Smart line is a chain of connected line segments and/or arc segments. Smart line can be created by creating LineString or LinearComplex objects. The below code snippet shows how to create a smart line using LinearComplex and create alignment for that smart line.
internal Alignment CreateAlignmentFromSmartLine()
{
//Create line to create complex line
Bentley.GeometryNET.DPoint3d startPoint1 = new DPoint3d(707074.878, 231801.166, 0);
Bentley.GeometryNET.DPoint3d endPoint1 = new DPoint3d(707505.580, 231599.077, 0);
Bentley.CifNET.LinearGeometry.Line line1 = Line.Create1(startPoint1, endPoint1);
//create arc to create complex line
Bentley.GeometryNET.DPoint3d curveStartPoint = new DPoint3d(707505.580, 231599.077, 0);
Bentley.GeometryNET.DPoint3d curveEndPoint = new DPoint3d(707527.726, 231597.626, 0);
double radius = 30.48;
Bentley.CifNET.LinearGeometry.Hand direction = Hand.CounterClockwise;
Bentley.CifNET.LinearGeometry.CircularArc arc = Bentley.CifNET.LinearGeometry.CircularArc.
Create4(curveStartPoint, curveEndPoint, radius, direction);
//Create line to create complex line
Bentley.GeometryNET.DPoint3d startPoint2 = new DPoint3d(707527.726, 231597.626, 0);
Bentley.GeometryNET.DPoint3d endPoint2 = new DPoint3d(707960.529, 231734.683, 0);
Bentley.CifNET.LinearGeometry.Line line2 = Line.Create1(startPoint2, endPoint2);
//add the lines and arc to list of LinearElements
System.Collections.Generic.List<LinearElement> lines = new List<LinearElement>();
lines.Add(line1);
lines.Add(arc);
lines.Add(line2);
//create smart line of type linearComplex from LinearElements list
Bentley.CifNET.LinearGeometry.LinearComplex smartLine = LinearComplex.Create1
(lines.ToArray(), false, false, 0.001);
Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit con = ConsensusConnectionEdit.GetActive();
Bentley.CifNET.GeometryModel.SDK.GeometricModel gm = con.GetOrCreateGeometricModel();
if (gm == null)
{
con.Close();
con.Dispose();
return null;
}
//begins mode to persist objects
con.StartTransientMode();
//create alignment from LinearComplex
Bentley.CifNET.GeometryModel.SDK.Alignment al = gm.CreateAlignmentByLinearElement
(smartLine, true);
//set feature definition
string featureDef = "Alignment\\Geom_Baseline";
if (featureDef != null && featureDef != string.Empty)
{
al.SetFeatureDefinition(featureDef);
}
//persist objects
con.PersistTransients();
return al;
}
CreateAlignmentByLinearElement() of GeometricModel creates an alignment from a smart line of type LinearComplex created from 2 lines and one arc. SetFeatureDefinition() sets the feature definition to an alignment.